﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Vote.aspx.cs" Inherits="Meeting.Web.Admin.BaseSet.Vote" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../../Scripts/jquery-1.8.2.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/cupertino/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/icon.css" />
    <!--ardialog-->
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/plugins/iframeTools.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../Scripts/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../Scripts/common.js"></script>
    <script src="../../Scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../../Scripts/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        var zTree;
        $(function () {
            if (request("psnID") == "") window.location = defaultUrl;
            InitGird();
        });

        function InitGird() {
            $('#mainList').datagrid({
                //title: '投票列表',
                url: "VoteOperation.ashx?method=GetVotes", //请求数据的页面
                sortName: 'Theme', //排序字段
                idField: 'Id', //标识字段,主键
                //iconCls: '', //标题左边的图标
                width: 800, //宽度 
                singleSelect: true,
                selectOnCheck: false,
                checkOnSelect: false,
                fitColumns: true,
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'asc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                {field: 'IsChecked', checkbox: true }
                ]],

                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                // rownumbers: true, //行号
                toolbar: [{
                    text: '添加',
                    iconCls: 'icon-add',
                    handler: function () {

                        var radStr = Math.random();
                        var url = 'VoteAdd.aspx?method=show&Id=&Radstr=' + radStr;
                        art.dialog.open(url, { title: '新建投票',
                            id: 'AAA', width: 700, height: 530, lock: true,
                            close: function () {
                                $("#mainList").datagrid("reload");
                            }
                        }, false);

                    }
                }, '-', {
                    text: '删除',
                    iconCls: 'icon-remove',
                    handler: function () {
                        $.messager.confirm('警告', '删除该投票其相关信息及投票结果将一并删除，确定吗?', function (e) {
                            if (!e) return;
                            DeleteData();
                        })
                    }
                }]
            });
            //            '-', {
            //                    text: '修改',
            //                    iconCls: 'icon-edit',
            //                    handler: function () {
            //                        EditData();
            //                    }
            //                },
            //设置分页
            var p = $("#mainList").datagrid("getPager");
            $(p).pagination({
                pageSize: 20, //每页显示的记录条数，默认为10   
                pageList: [10, 20, 30], //可以设置每页记录条数的列表   
                beforePageText: '第', //页数文本框前显示的汉字   
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'

            });
        }
          

        //删除投票
        function DeleteData() {
            var ss = '';
            var rows = $('#mainList').datagrid('getChecked');
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                ss += "'" + row.Id + "',";
            }
            if (ss.length > 0) ss = ss.substr(0, ss.length - 1);

            if (ss.length == 0) {
                $.messager.alert("提示", '请选择要删除的行！');
                return;
            }

            var postData = { id: ss };
            $.post("VoteOperation.ashx?method=delete", postData, function (data) {
                if (data.success == true) {
                    $.messager.alert("提示", '删除成功');
                    $("#mainList").datagrid('reload');
                } else {
                    $.messager.alert("提示", data.Message);
                }
            });

        }



        function EditSort() {
            var rows = $('#officeList').datagrid('getRows');
            for (i = 0; i < rows.length; i++) {
                $('#officeList').datagrid('beginEdit', i);
            }
        }
        //分局信息选择 
        function AddOffice() {
            var radStr = Math.random();
            var url = "../SelectBase/SelectSubOffice.aspx" + '?Radstr=' + radStr;
            art.dialog.open(url, {
                id: 'AddOffice', title: '选择分局', width: 500, height: 430, lock: true,
                follow: document.getElementById('selOffice'),
                close: function () {
                    var selNodeJson = art.dialog.data('selNode'); // 读取人员选择返回值
                    //  alert(selNodeJson);
                    if (selNodeJson != "") {
                        try {
                            var data = JSON.parse(selNodeJson);
                            DelAll();
                            for (i = 0; i < data.length; i++) {
                                $('#officeList').datagrid('appendRow', data[i]);
                            }
                        } catch (ex) { }
                    }
                }
            }, true);
        }

        function DelAll() {
            var rows = $('#officeList').datagrid('getRows');
            for (i = rows.length - 1; i >= 0; i--) {
                $('#officeList').datagrid('deleteRow', i);
            }
        } function DoSearch() {
            $('#mainList').datagrid('reload', {
                Name: $("#fName").val(),
                Begin: $("#txtBeginTime").val(),
                End: $("#txtEndTime").val()
            });
        } 
    </script>
    <style type="text/css">
        .table_edit
        {
            text-align: right;
        }
        .table_edit tr
        {
            height: 32px;
        }
        input, textarea
        {
            border: 1px solid #AED0EA;
            padding: 2px;
            height: 16px;
        }
        
        
        
        .datagrid-row-selected
        {
            background: #d7ebf9;
            color: #000;
        }
        
        .datagrid-row-click
        {
            background: #3baae3;
            color: #fff;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table class="SearchTable">
        <tr>
            <td>
               投票主题:
            </td>
            <td>
                <input id="fName" style="width: 120px;" class="easyui-validatebox" />
            </td>
            <td>
                发起时间:
            </td>
            <td>
                <input id="txtBeginTime" onfocus="WdatePicker({startDate:'%y-%M-01 00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"
                    style="width: 120px" />
            </td>
            <td>
                ~
            </td>
            <td>
                <input id="txtEndTime" onfocus="WdatePicker({startDate:'%y-%M-01 00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"
                    style="width: 120px" />
            </td>
            <td>
                <a href="#" class="easyui-linkbutton" onclick="DoSearch();">查询</a>
            </td>
        </tr>
    </table>
    <div style="min-height: 500px; width: 800px; text-align: left;"> 
        <table id="mainList">
            <thead>
                <tr>
                    <th data-options="field:'Id',hidden:true, width:120">
                        会议编号
                    </th>
                    <th data-options="field:'Theme',width:120">
                        投票主题
                    </th>
                    <th data-options="field:'Category',width:120,formatter:formatCategory">
                        投票类型
                    </th>
                    <th data-options="field:'EmployeeName',width:120">
                        发起人
                    </th>
                    <th data-options="field:'StartDate',width:120">
                        发起时间
                    </th>
                    <th data-options="field:'EndDate',width:120">
                        截止时间
                    </th>
                    <%-- <th data-options="field:'IsActive',width:120,formatter:formatIsActive">
                        是否有效
                    </th>--%>
                </tr>
            </thead>
        </table>
        <script type="text/javascript">
            function formatCategory(val, row) {
                if (val == 1) {
                    return "单选";
                } else if (val == 2) {
                    return "多选";
                } else if (val == 3) {
                    return "打分";
                } else if (val == 4) {
                    return "分局打分";
                }
                return "";
            }
            
        </script>
    </div>
    </form>
</body>
</html>
